package com.leetcode.LeetCode精选TOP面试题;

/**
 * @author 覃国强
 * @date 2022-07-05 17:06
 */
public class 题库_0171_Excel表列序号 {

  static
  class Solution {
    public int titleToNumber(String columnTitle) {
      if (columnTitle == null || columnTitle.length() == 0) {
        return 0;
      }
      int answer = 0;
      int radix = 1;
      for (int i = columnTitle.length() - 1; i >= 0; --i) {
        answer = (columnTitle.charAt(i) - 'A' + 1) * radix + answer;
        radix *= 26;
      }
      return answer;
    }
  }

}
